added iOS source code
[wl-app.git] / iOS / Pods / Target Support Files / Pods-WolneLektury / Pods-WolneLektury-frameworks.sh
1 #!/bin/sh
2 set -e
3 set -u
4 set -o pipefail
5
6 if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
7     # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
8     # frameworks to, so exit 0 (signalling the script phase was successful).
9     exit 0
10 fi
11
12 echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
13 mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
14
15 COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}"
16 SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
17
18 # Used as a return value for each invocation of `strip_invalid_archs` function.
19 STRIP_BINARY_RETVAL=0
20
21 # This protects against multiple targets copying the same framework dependency at the same time. The solution
22 # was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html
23 RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????")
24
25 # Copies and strips a vendored framework
26 install_framework()
27 {
28   if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
29     local source="${BUILT_PRODUCTS_DIR}/$1"
30   elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
31     local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
32   elif [ -r "$1" ]; then
33     local source="$1"
34   fi
35
36   local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
37
38   if [ -L "${source}" ]; then
39       echo "Symlinked..."
40       source="$(readlink "${source}")"
41   fi
42
43   # Use filter instead of exclude so missing patterns don't throw errors.
44   echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
45   rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
46
47   local basename
48   basename="$(basename -s .framework "$1")"
49   binary="${destination}/${basename}.framework/${basename}"
50   if ! [ -r "$binary" ]; then
51     binary="${destination}/${basename}"
52   fi
53
54   # Strip invalid architectures so "fat" simulator / device frameworks work on device
55   if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
56     strip_invalid_archs "$binary"
57   fi
58
59   # Resign the code if required by the build settings to avoid unstable apps
60   code_sign_if_enabled "${destination}/$(basename "$1")"
61
62   # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
63   if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
64     local swift_runtime_libs
65     swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u  && exit ${PIPESTATUS[0]})
66     for lib in $swift_runtime_libs; do
67       echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
68       rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
69       code_sign_if_enabled "${destination}/${lib}"
70     done
71   fi
72 }
73
74 # Copies and strips a vendored dSYM
75 install_dsym() {
76   local source="$1"
77   if [ -r "$source" ]; then
78     # Copy the dSYM into a the targets temp dir.
79     echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\""
80     rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}"
81
82     local basename
83     basename="$(basename -s .framework.dSYM "$source")"
84     binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}"
85
86     # Strip invalid architectures so "fat" simulator / device frameworks work on device
87     if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then
88       strip_invalid_archs "$binary"
89     fi
90
91     if [[ $STRIP_BINARY_RETVAL == 1 ]]; then
92       # Move the stripped file into its final destination.
93       echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\""
94       rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}"
95     else
96       # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing.
97       touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM"
98     fi
99   fi
100 }
101
102 # Signs a framework with the provided identity
103 code_sign_if_enabled() {
104   if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
105     # Use the current code_sign_identitiy
106     echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
107     local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
108
109     if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
110       code_sign_cmd="$code_sign_cmd &"
111     fi
112     echo "$code_sign_cmd"
113     eval "$code_sign_cmd"
114   fi
115 }
116
117 # Strip invalid architectures
118 strip_invalid_archs() {
119   binary="$1"
120   # Get architectures for current target binary
121   binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)"
122   # Intersect them with the architectures we are building for
123   intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)"
124   # If there are no archs supported by this binary then warn the user
125   if [[ -z "$intersected_archs" ]]; then
126     echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)."
127     STRIP_BINARY_RETVAL=0
128     return
129   fi
130   stripped=""
131   for arch in $binary_archs; do
132     if ! [[ "${ARCHS}" == *"$arch"* ]]; then
133       # Strip non-valid architectures in-place
134       lipo -remove "$arch" -output "$binary" "$binary" || exit 1
135       stripped="$stripped $arch"
136     fi
137   done
138   if [[ "$stripped" ]]; then
139     echo "Stripped $binary of architectures:$stripped"
140   fi
141   STRIP_BINARY_RETVAL=1
142 }
143
144
145 if [[ "$CONFIGURATION" == "Debug" ]]; then
146   install_framework "${BUILT_PRODUCTS_DIR}/AEXML/AEXML.framework"
147   install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework"
148   install_framework "${BUILT_PRODUCTS_DIR}/AlamofireActivityLogger/AlamofireActivityLogger.framework"
149   install_framework "${BUILT_PRODUCTS_DIR}/FolioReaderKit/FolioReaderKit.framework"
150   install_framework "${BUILT_PRODUCTS_DIR}/FontBlaster/FontBlaster.framework"
151   install_framework "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework"
152   install_framework "${BUILT_PRODUCTS_DIR}/JSQWebViewController/JSQWebViewController.framework"
153   install_framework "${BUILT_PRODUCTS_DIR}/Kingfisher/Kingfisher.framework"
154   install_framework "${BUILT_PRODUCTS_DIR}/MBProgressHUD/MBProgressHUD.framework"
155   install_framework "${BUILT_PRODUCTS_DIR}/MZDownloadManager/MZDownloadManager.framework"
156   install_framework "${BUILT_PRODUCTS_DIR}/MatomoTracker/MatomoTracker.framework"
157   install_framework "${BUILT_PRODUCTS_DIR}/MenuItemKit/MenuItemKit.framework"
158   install_framework "${BUILT_PRODUCTS_DIR}/OAuthSwift/OAuthSwift.framework"
159   install_framework "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework"
160   install_framework "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework"
161   install_framework "${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework"
162   install_framework "${BUILT_PRODUCTS_DIR}/SSZipArchive/SSZipArchive.framework"
163   install_framework "${BUILT_PRODUCTS_DIR}/SideMenu/SideMenu.framework"
164   install_framework "${BUILT_PRODUCTS_DIR}/SwiftKeychainWrapper/SwiftKeychainWrapper.framework"
165   install_framework "${BUILT_PRODUCTS_DIR}/Toast-Swift/Toast_Swift.framework"
166   install_framework "${BUILT_PRODUCTS_DIR}/ZFDragableModalTransition/ZFDragableModalTransition.framework"
167   install_framework "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework"
168 fi
169 if [[ "$CONFIGURATION" == "Release" ]]; then
170   install_framework "${BUILT_PRODUCTS_DIR}/AEXML/AEXML.framework"
171   install_framework "${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework"
172   install_framework "${BUILT_PRODUCTS_DIR}/AlamofireActivityLogger/AlamofireActivityLogger.framework"
173   install_framework "${BUILT_PRODUCTS_DIR}/FolioReaderKit/FolioReaderKit.framework"
174   install_framework "${BUILT_PRODUCTS_DIR}/FontBlaster/FontBlaster.framework"
175   install_framework "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework"
176   install_framework "${BUILT_PRODUCTS_DIR}/JSQWebViewController/JSQWebViewController.framework"
177   install_framework "${BUILT_PRODUCTS_DIR}/Kingfisher/Kingfisher.framework"
178   install_framework "${BUILT_PRODUCTS_DIR}/MBProgressHUD/MBProgressHUD.framework"
179   install_framework "${BUILT_PRODUCTS_DIR}/MZDownloadManager/MZDownloadManager.framework"
180   install_framework "${BUILT_PRODUCTS_DIR}/MatomoTracker/MatomoTracker.framework"
181   install_framework "${BUILT_PRODUCTS_DIR}/MenuItemKit/MenuItemKit.framework"
182   install_framework "${BUILT_PRODUCTS_DIR}/OAuthSwift/OAuthSwift.framework"
183   install_framework "${BUILT_PRODUCTS_DIR}/Protobuf/Protobuf.framework"
184   install_framework "${BUILT_PRODUCTS_DIR}/Realm/Realm.framework"
185   install_framework "${BUILT_PRODUCTS_DIR}/RealmSwift/RealmSwift.framework"
186   install_framework "${BUILT_PRODUCTS_DIR}/SSZipArchive/SSZipArchive.framework"
187   install_framework "${BUILT_PRODUCTS_DIR}/SideMenu/SideMenu.framework"
188   install_framework "${BUILT_PRODUCTS_DIR}/SwiftKeychainWrapper/SwiftKeychainWrapper.framework"
189   install_framework "${BUILT_PRODUCTS_DIR}/Toast-Swift/Toast_Swift.framework"
190   install_framework "${BUILT_PRODUCTS_DIR}/ZFDragableModalTransition/ZFDragableModalTransition.framework"
191   install_framework "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework"
192 fi
193 if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then
194   wait
195 fi